<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="./css/bootstrap.css">
    <link rel="stylesheet" href="./css/font-awesome.css">
</head>
<body>
    
    <div class="container">
        <div class="row justify-content-center">
            <div class="col-md-12 ">
            <h3>用户列表</h3>
    <a class="btn btn-success" href="./insert.html">插入用户数据 <i class="fa fa-plus-square fa-fw"></i></a>

    
        <table class="table table-bordered">
        <thead class="thead-dark ">
            <tr>
            <th>#</th>
            <th>id</th>
            <th>姓名</th>
            <th>邮箱</th>
            <th>电话号码</th>
            <th>操作</th>
            </tr>
        </thead>
     
        <tbody>
        <?php
    // 引入数据库链接文件
    require_once "./conn.php";
    // 获取结果记录集
    $result = mysqli_query($link,"select * from users");
    if(mysqli_num_rows($result)>0){
    //   var_dump( mysqli_fetch_all($result,MYSQLI_ASSOC));
    $i=1;
    while ($row=mysqli_fetch_array($result)) {
    ?>
            <tr>
            <th><?php echo $i; ?></th>
            <td><?php echo $row['id']; ?></td>
            <td><?php echo $row['name']; ?></td>
            <td><?php echo $row['email']; ?></td>
            <td><?php echo $row['mobile']; ?></td>
            <td> 
                <a class="btn btn-success" href="./update.php?id=<?php echo $row['id']; ?>"><i class="fa fa-pencil "> 修改</i></a>
                <a class="btn btn-success" href=""><i class="fa fa-plus-square"> 删除</i></a>
            </td>
            </tr>
            <?php
            $i++;
            }
        } else{
            echo "<tr><td colspan='6' class='text-center'>无记录！</td></tr>";
        }
?>
        </tbody>
   
        </table>


            </div>
        </div>
    </div>
   

</body>
</html>